package logic

import (
	"context"
	"housing/houserpc/houserpc"

	"housing/api/internal/svc"
	"housing/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type HouseListSmsLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewHouseListSmsLogic(ctx context.Context, svcCtx *svc.ServiceContext) *HouseListSmsLogic {
	return &HouseListSmsLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *HouseListSmsLogic) HouseListSms(req *types.HouseListRequest) (resp *types.Response, err error) {
	// todo: add your logic here and delete this line
	list, err := l.svcCtx.HouseRpc.HouseList(l.ctx, &houserpc.HouseListRequest{
		Page:       req.Page,
		Size:       req.Size,
		PriceOrder: req.PriceOrder,
		TimeOrder:  req.TimeOrder,
	})
	if err != nil {
		return &types.Response{
			Message: err.Error(),
			Code:    500,
			Data:    nil,
		}, nil
	} else {
		return &types.Response{
			Message: "房源列表展示成功",
			Code:    200,
			Data:    list,
		}, nil
	}
}
